package io.gitee.kotle.player.ui.view.exo

import android.view.MotionEvent
import android.view.View
import androidx.lifecycle.MutableLiveData
import androidx.media3.common.MediaItem
import io.gitee.kotle.player.core.IPlayer
import io.gitee.kotle.player.core.impl.exoplayer.IExoPlayerMode
import io.gitee.kotle.player.ui.BasePlayerViewConfig
import io.gitee.kotle.player.ui.view.PlayerGestureDetectorHelper

/**
 *交互逻辑配置类
 */

open class ExoPlayerViewConfig<Model : IExoPlayerMode>(player: IPlayer<MediaItem, Model>) :
    BasePlayerViewConfig<MediaItem, Model>(
        player
    ) {

    /**
     * 设置手势管理器对象
     */
    @Suppress("UNCHECKED_CAST")
    var playerGestureDetectorHelper: Function1<View, PlayerGestureDetectorHelper> = {
        ExoPlayerGestureDetectorHelper(it, this as ExoPlayerViewConfig<IExoPlayerMode>)
    }

    /**
     * 是否允许手势操作
     */
    val gestureEnable by lazy { MutableLiveData<Boolean>() }

    /**
     * 当前音量
     */
    val currentVolume by lazy { MutableLiveData<Float>() }

    /**
     * 是否调节得系统音量
     */
    val isAdjustSystemVolume by lazy { MutableLiveData<Boolean>() }

    /**
     * 当前屏幕亮度
     */
    val screenBrightness by lazy { MutableLiveData<Float>() }

    /**
     * 是否允许双击
     */
    val enableDoubleClick by lazy { MutableLiveData<Boolean>() }

    /**
     * 单击事件
     * Boolean:当前状态 true/false  交替,
     *         null 则移除所有回调
     */
    val singleTapConfirmed by lazy { MutableLiveData<Boolean>() }

    /**
     * 触摸事件
     */
    val motionEvent by lazy { MutableLiveData<MotionEvent>() }

    /**
     * 滑动事件
     */
    val seekBarProgress by lazy { MutableLiveData<Pair<Boolean/*是否抬手*/, Float/*百分比0-1f*/>>() }

    /**
     * 一次滑动允许的最大时长
     */
    val allMaxSeekProgressMs by lazy { MutableLiveData<Long/*允许最大时长*/>() }

    /**
     * 默认的长按倍速
     */
    val longPressVideoSpeed by lazy { MutableLiveData<Float>() }

    /**
     * 长按事件
     */
    val longPressEvent by lazy { MutableLiveData<Float>() }
}